

//
//  UIBarButtonItem+Extension.m
//  黑马微博-wzy
//
//  Created by Mac on 2016/11/27.
//  Copyright © 2016年 Mac. All rights reserved.
//

#import "UIBarButtonItem+Extension.h"

@implementation UIBarButtonItem (Extension)

+ (UIBarButtonItem *)itemWithImageName:(NSString *)imageName hightImageName:(NSString *)hightImageName target:(id)target action:(SEL)action{
    //添加导航按钮
    UIButton *button = [[UIButton alloc] init];
    [button setBackgroundImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
    [button setBackgroundImage:[UIImage imageNamed:hightImageName] forState:UIControlStateHighlighted];
    //注意 target 需是控制器
    [button addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    button.size = button.currentBackgroundImage.size;
    //设置导航栏 按钮
    return [[UIBarButtonItem alloc] initWithCustomView:button];;
    
}


@end
